package com.item.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import com.base.mobile.MobileInfo;

public class ApiUtil {
	
	public static Map<String,String> createParamMaps(){
		Map<String,String> map = new HashMap<String, String>();
		return map;
	}
	
	public static String getNextPageUrl(String mothodno, MobileInfo mobileInfo,Integer total,Integer page,Integer limit,Map<String,String> params){
        String result;
		if(Math.ceil((float)total/limit) <= page){
			result = "";
		}else{
			StringBuilder sb = new StringBuilder();
			sb.append(String.format(ConstantResources.APIPAGEURL, ConstantResources.SERVERAPIURL,
					mothodno,mobileInfo.getDeviceid(),mobileInfo.getUserid(),mobileInfo.getAppid(),page+1,limit));
			if(params != null && params.size() > 0){
				Iterator<Entry<String, String>> itr = params.entrySet().iterator();
				while(itr.hasNext()){
					Map.Entry<String, String> entry = (Map.Entry<String, String>)itr.next();
					sb.append(String.format("&%s=%s", entry.getKey(),entry.getValue()));
				}
			}
			result = sb.toString();
		}
		return result;
	}
	
	
}
